package com.view;

import com.dao.UserDao;
import com.dao.impl.UserDaoImpl;
import com.view.impl.AccountView;
import com.view.impl.ReportView;

import java.util.Map;

import static com.util.Read.getIn;

public class LoginView  {
    private UserDao userDao = new UserDaoImpl();
    private Map<String,Object> info;

    public Map<String, Object> getInfo() {
        return info;
    }

    public void setInfo(Map<String, Object> info) {
        this.info = info;
    }

    public Map<String, Object> login() {
        Map<String, Object> map = null;
        System.out.println("请输入账号：");
        String name = getIn().next();
        System.out.println("请输入密码：");
        String pwd = getIn().next();
        map= userDao.login(name,pwd);
        return map;
    }
    public void menu(){
        System.out.println("记账本功能如下:");
        System.out.println("1.记录账单/t 2.查看报表");
        System.out.println("请选择功能:");
        int n = getIn().nextInt();
        switch (n) {
            case 1:
                AccountView accountView = new AccountView();
                accountView.setInfo(info);
                accountView.insert();
                break;
            case 2:

                ReportView reportView = new ReportView();
                reportView.setInfo(info);
                reportView.menua();
                break;
            default:
                System.out.println("请选择正确的功能！");
                break;
        }

    }
}
